package l.l.w.网易2018实习.被3整除;

import java.util.Scanner;

/**
 * Created by llw on 2018/3/28/0028.
 */
public class Main1 {
    static int [] DigitTens = {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
            2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
            3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
            4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
            5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
            6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
            7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
            8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
            9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
    } ;
    static int [] DigitOnes = {
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
            0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
    } ;
    static int [] digits = {
            0 , 1 , 2 , 3 , 4 , 5 ,
            6 , 7 , 8 , 9
    };
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int l = scanner.nextInt();
        int r = scanner.nextInt();
        int count = 0;
        int start = 0;
        int sum = 0;
        for(int i = 1; i < l; ++i){
            sum+=getSum(i);
        }
        for(int i = l; i <= r; ++i){
            sum+=getSum(i);
            if(sum % 3 == 0){
                count++;
            }
        }
        System.out.println(count);
    }

    private static int getSum(int i) {
        int k = 0;
        int t = 0;
        int sum = 0;
        while (i >= 65536){
            k = i / 100;
            t = i - ((k << 6) + (k << 5) + (k << 2));
            i = k;
            sum += DigitOnes[t];
            sum += DigitTens[t];
        }
        for (;;) {
            k = (i * 52429) >>> (16+3);
            t = i - ((k<< 3) + (k << 1));  // r = i-(q*10) ...
            sum += digits [t];
            i = k;
            if (i == 0) break;
        }
        return sum;
    }
}